#include "bits/stdc++.h"
using namespace std;
template<class T>
struct Fenwick2D {
  using type = array<T, 4>;
  Fenwick2D(int n, int m) : n_(n), m_(m), tr_(n + 1, vector<type>(m + 1, {0, 0, 0, 0})) {}
  
  void modify(int x, int y, T v) {
    for (int i = x; i <= n_; i += (i & -i)) {
      for (int j = y; j <= m_; j += (j & -j)) {
        tr_[i][j][0] += v;
        tr_[i][j][1] += v * x;
        tr_[i][j][2] += v * y;
        tr_[i][j][3] += v * x * y;
      }
    }
  }

  T query(int x, int y) {
    T result = 0;
    for (int i = x; i > 0; i -= (i & -i)) {
      for (int j = y; j > 0; j -= (j & -j)) {
        result += T(1) * (x + 1) * (y + 1) * tr_[i][j][0];
        result -= T(1) * (y + 1) * tr_[i][j][1];
        result -= T(1) * (x + 1) * tr_[i][j][2];
        result += T(1) * tr_[i][j][3];
      }
    }
    return result;
  }

  void add(int x1, int y1, int x2, int y2, T v) {
    modify(x1, y1, v);
    modify(x2 + 1, y1, -v);
    modify(x1, y2 + 1, -v);
    modify(x2 + 1, y2 + 1, v);
  }

  T sum(int x1, int y1, int x2, int y2) {
    return query(x2, y2) - query(x1 - 1, y2) - query(x2, y1 - 1) + query(x1 - 1, y1 - 1);
  }

  int n_, m_;
  vector<vector<type>> tr_;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  char op;
  int x1, y1, x2, y2;
  cin >> op >> x1 >> y1;
  Fenwick2D<int> fen(x1, y1);

  while (cin >> op >> x1 >> y1 >> x2 >> y2) {
    int v;
    if (op == 'L') {
      cin >> v;
      fen.add(x1, y1, x2, y2, v);
    } else {
      cout << fen.sum(x1, y1, x2, y2) << '\n';
    }
  }
  return 0;
}